
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
<script language="javascript">
   function date(){     //document.getElementById验证
	   var date=document.getElementById("Tel").value;
	   if(!date.match(/^(\d{4}-\d{2}-\d{2})$/)) 
	      alert("请输入正确的日期格式，如2017-11-21");
		  }
	function submit2(){     
	   var submit2=document.all.Tel.value;
	   if(!submit2.match(/^(\d{4}-\d{2}-\d{2})$/))
	   alert("请输入正确的日期格式，如2017-11-21");
	   }
</script>
</head>
<body>
<form name="form1">
联系电话：<input type="text" name="Tel" id="Tel"/> 
<input type="button" value="date" onClick="return date()"/>
<input type="button" value="submit2" onClick="return submit2()"/>
</form>
</body>
</html>
